{include file="public/header" /}



<div class="page">
    <div class="fixed-empty"></div>
    <form id="link_form" enctype="multipart/form-data" method="post">
        <table class="sc-default-table">
            <tbody>
            <tr class="noborder">
                <td colspan="2" class="required">{$Think.lang.sc_class}:</td>
            </tr>
            {if $Request.action eq 'mb_category_edit'}
            <tr class="noborder">
                <td class="vatop rowform">
                    {$goods_class[$link_array.gc_id]['gc_name']}
                </td>
                <td class="vatop tips"></td>
            </tr>
            {/if}
            {if $Request.action eq 'mb_category_add'}
            <tr class="noborder">
                <td class="vatop rowform">
                    <select name="link_category" id="link_category">
                        {foreach name="goods_class" item="v"}
                        <?php if ($v['gc_parent_id'] != '0') break;?>
                        <option value="{$v.gc_id}">{$v.gc_name}</option>
                        {/foreach}
                    </select>
                </td>
                <td class="vatop tips">{$Think.lang.link_add_href}</td>
            </tr>
            {/if}
            <tr class="noborder">
                <td class="required"><label for="">{$Think.lang.link_index_pic_sign}:</label></td>
                <td class="vatop rowform">
                    {notempty name="$link_array.gc_thumb"}
                    <span class="type-file-show"><img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
                        <div class="type-file-preview"><img src="{$Think.UPLOAD_SITE_URL}/{$Think.ATTACH_MOBILE}/category/{$link_array.gc_thumb}"></div>
                    </span>
                    {/notempty}
                    <span class="type-file-box">
                        <input name="link_pic" type="file" class="type-file-file" id="link_pic" size="30">
                    </span>
                </td>
                <td class="vatop tips">展示图片，建议大小300px*120px</td>
            </tr>
            <tfoot>
            <tr class="tfoot">
                <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>{$Think.lang.sc_submit}</span></a></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>

<script>
    //按钮先执行验证再提交表单
    $(function(){$("#submitBtn").click(function(){
        if($("#link_form").valid()){
            $("#link_form").submit();
        }
    });
    });
    //
    $(document).ready(function(){
        $('#link_form').validate({
            errorPlacement: function(error, element){
                error.appendTo(element.parent().parent().prev().find('td:first'));
            },

            rules : {
                link_title : {
                    required : true
                },
                link_url  : {
                    required : true,
                    url      : true
                },
                link_sort : {
                    number   : true
                }
            },
            messages : {
                link_title : {
                    required : '{$Think.lang.link_add_title_null}'
                },
                link_url  : {
                    required : '{$Think.lang.link_add_url_null}',
                    url      : '{$Think.lang.link_add_url_wrong}'
                },
                link_sort  : {
                    number   : '{$Think.lang.link_add_sort_int}'
                }
            }
        });
    });
</script>
<script type="text/javascript">
    $(function(){
        var textButton="<input type='text' name='textfield' id='textfield1' class='type-file-text' />" +
            "<input type='button' name='button' id='button1' value='' class='type-file-button' />"
        $(textButton).insertBefore("#link_pic");
        $("#link_pic").change(function(){
            $("#textfield1").val($("#link_pic").val());
        });
    });
</script>